home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / man / man-part1 / cat6 / odedc.6 < prev    next >
Text File  |  1999-09-16  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4. odedc(G)                       Scilab Function                       odedc(G)
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. NAME
  12.   odedc - discrete/continuous ode solver
  13.  
  14. CALLING SEQUENCE
  15.   yt=odedc(y0,nd,stdel,t0,t,f)
  16.  
  17. PARAMETERS
  18.  
  19.   y0        : real column vector (initial conditions),y0=[y0c;y0d] where y0d
  20.             has nd components.
  21.  
  22.   nd        : integer, dimension of y0d
  23.  
  24.   stdel     : real vector with two entries, stdel=[step, delay]
  25.  
  26.   t0        : real scalar (initial time).
  27.  
  28.   t         : real (row) vector, instants where yt is calculated
  29.  
  30.   f         : Scilab "external" i.e. function or character string or list
  31.             with calling sequence: yp=f(t,yc,yd,flag)
  32.  
  33. DESCRIPTION
  34.  
  35.   y=odedc([y0c;y0d],nd,[h,delta],t0,t,f) computes the solution of:
  36.  
  37.    dyc/dt=f(t,yc,yd,0) , yc(t0)=y0c,
  38.  
  39.   such that at instants td=[delta, delta+h, delta+2*h,...] the discrete vari-
  40.   able yd is updated by:
  41.  
  42.   yd(td+)=f(yc(t-),yd(t-1),1)
  43.  
  44.   The calling parameters of f are fixed: xcd=f(t,xc,xd,flag); this function
  45.   must return the derivative of the vector xc if flag=0 and the update of xd
  46.   if flag=1.
  47.  
  48.   t is a vector of instants where the solution y is computed.
  49.  
  50.   y is the vector y=[y(t(1)),y(t(2)),...].  This function can be called with
  51.   the same optional parameters as the ode function (provided nd and stdel are
  52.   given in the calling sequence as second and third parameters).  It particu-
  53.   lar integration flags, tolerances can be set. Optional parameters can be
  54.   set by the odeoptions function.
  55.  
  56. EXAMPLE
  57.   //Linear system with switching input
  58.   deff('xdu=f(t,x,u,flag)','if flag=0 then xdu=A*x+B*u; else xdu=1-u;end');
  59.   x0=[1;1];A=[-1,2;-2,-1];B=[1;2];u=0;nu=1;stdel=[1,0];u0=0;t=0:0.05:10;
  60.   xu=odedc([x0;u0],nu,stdel,0,t,f);x=xu(1:2,:);u=xu(3,:);
  61.   [xi,xa,npx]=graduate(min(t),1.1*max(t));
  62.   [yi,ya,npy]=graduate(1.1*min(min(x),min(u)),1.1*max(max(x),max(u)));
  63.   rect=[xi,yi,xa,ya];nx=2;//cont. componemts
  64.   plot2d1('onn',t',x',-[1:nx],'111',' ',rect,[4,npx,2,npy]);
  65.   plot2d2('onn',t',u',-[nx+1:nx+nu],'111',' ',rect,[4,npx,2,npy]);
  66.  
  67.   //Sampled feedback
  68.   //
  69.   //             |     xcdot=fc(t,xc,u)
  70.   //  (system)   |
  71.   //             |     y=hc(t,xc)
  72.   //
  73.   //
  74.   //             |     xd+=fd(xd,y)
  75.   //  (feedback) |
  76.   //             |     u=hd(t,xd)
  77.   //
  78.   deff('xcd=f(t,xc,xd,iflag)',...
  79.     xcd=fc(t,xc,e(t)-hd(t,xd));...
  80.     else xcd=fd(xd,hc(t,xc));end');
  81.   comp(f);
  82.   A=[-10,2,3;4,-10,6;7,8,-10];B=[1;1;1];C=[1,1,1];
  83.   Ad=[1/2,1;0,1/20];Bd=[1;1];Cd=[1,1];
  84.   deff('st=e(t)','st=sin(3*t)')
  85.   deff('xdot=fc(t,x,u)','xdot=A*x+B*u')
  86.   deff('y=hc(t,x)','y=C*x')
  87.   deff('xp=fd(x,y)','xp=Ad*x + Bd*y')
  88.   deff('u=hd(t,x)','u=Cd*x')
  89.   comp(e);comp(fc);comp(hc);comp(fd);comp(hd);
  90.   h=0.1;t0=0;t=0:0.1:2;
  91.   x0c=[0;0;0];x0d=[0;0];nd=2;
  92.   xcd=odedc([x0c;x0d],nd,h,t0,t,f);
  93.   plot2d([t',t',t'],xcd(1:3,:)');
  94.   xset("window",2);plot2d2("gnn",[t',t'],xcd(4:5,:)');
  95.   xset("window",0);
  96.  
  97. SEE ALSO
  98.   ode, odeoptions, csim, external, directory SCIDIR/default
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.